<?php
// +---------------------------------------------------------------------------+
// | This file is part of the KnowledgebasePublisher package                   |
// | KnowledgebasePublisher - web based knowledgebase publisher tool           |
// |                                                                           |
// | Author:  Evgeny Leontev <eleontev@gmail.com>                              |
// | Copyright (c) 2005 Evgeny Leontev                                         |
// |                                                                           |
// | For the full copyright and license information, please view the LICENSE   |
// | file that was distributed with this source code.                          |
// +---------------------------------------------------------------------------+

class RoleModel extends AppModel
{
	
	var $tbl_pref_custom = '';
	var $tables = array('table'=>'role', 'role', 'user');
	
	var $role_keys  = array('member_role'=>'member', 'user_role'=>'admin');
	
	
	function getSelectRange($role) {
		$sql = "SELECT id, title FROM {$this->tbl->table} WHERE role_key = '$role'";
		$result =& $this->db->Execute($sql) or die(db_error($sql));
		return $result->GetAssoc();
	}
	
	
	
	// ACTIONS // ---------------------	
	
	
	// DELETE RELATED // ---------------------
	function inUse($id, $table) {
		$sql = "SELECT COUNT(*) AS num 
		FROM {$table} u 
		WHERE u.role_id = '{$id}'";
		$result =& $this->db->Execute($sql, $record_id) or die(db_error($sql));
		return $result->Fields('num');
	}
}
?>
